// 创建路由器 ,创建路由的方法, 浏览器历史记录
import { createRouter, createWebHistory, createWebHashHistory } from 'vue-router';

//  vue 是一个单文件组件,模拟出 类似浏览器跳转页面的效果
// 并没有跳转页面,只是改变了页面的显示内容
// import routes from './routes'; 

import IndexView from '../views/IndexView.vue';
import BookView from '../views/BookView.vue';
import NotFound from '../views/NotFound.vue';

import HotView from '../views/book/HotView.vue';
import FollowingView from '../views/book/FollowingView.vue';
let routes = [
  { path: "/", component: IndexView },
  { path: "/index", component: IndexView },
  {
    path: "/book", component: BookView,
    // 路由的嵌套  /book/hot  /book/following
    children:[
      {path: "hot", component: HotView},
      {path: "following", component: FollowingView}
    ]

  },
  { path: "/:pathMatch(.*)*", component: NotFound },
]
// export 导出路由器,交给vue 使用
export const router = new createRouter({
  // 如何在浏览器里边显示
  history: createWebHistory(),
  // 所有的路线
  routes
})